<html>
<head><meta charset="utf-8"><title>Debuginfo treats projection like uses of the base local · t-compiler/wg-mir-opt · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/index.html">t-compiler/wg-mir-opt</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Debuginfo.20treats.20projection.20like.20uses.20of.20the.20base.20local.html">Debuginfo treats projection like uses of the base local</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="212084125"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Debuginfo%20treats%20projection%20like%20uses%20of%20the%20base%20local/near/212084125" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Debuginfo.20treats.20projection.20like.20uses.20of.20the.20base.20local.html#212084125">(Oct 02 2020 at 14:47)</a>:</h4>
<p>MIR may contain debuginfo like this after inlining:</p>
<div class="codehilite"><pre><span></span><code>    scope 1 {
        debug x =&gt; _3;                   // in scope 1 at $DIR/inline-closure-captures.rs:11:9: 11:10
        scope 2 {
            debug _q =&gt; _10;             // in scope 2 at $DIR/inline-closure-captures.rs:11:14: 11:16
            debug q =&gt; (*((*_6).0: &amp;i32)); // in scope 2 at $DIR/inline-closure-captures.rs:10:23: 10:24
            debug t =&gt; (*((*_6).1: &amp;T)); // in scope 2 at $DIR/inline-closure-captures.rs:10:17: 10:18
            let mut _9: T;               // in scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9
        }
    }
</code></pre></div>


<p>Here, the field access <code>(*_6).0</code> is treated like an actual use of the <code>_6</code> local in MIR visitors (<code>PlaceContext::NonMutatingUse</code>), even though it isn't really a use. This confuses the MIR validator and may also affect other passes. Is this intentional, or should this be changed to use <code>PlaceContext::NonUse(NonUseContext::VarDebugInfo)</code> instead?</p>



<a name="212084250"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Debuginfo%20treats%20projection%20like%20uses%20of%20the%20base%20local/near/212084250" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Debuginfo.20treats.20projection.20like.20uses.20of.20the.20base.20local.html#212084250">(Oct 02 2020 at 14:48)</a>:</h4>
<p>oh... yea, we should not make debug info treat this as a use</p>



<a name="212084635"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Debuginfo%20treats%20projection%20like%20uses%20of%20the%20base%20local/near/212084635" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Debuginfo.20treats.20projection.20like.20uses.20of.20the.20base.20local.html#212084635">(Oct 02 2020 at 14:51)</a>:</h4>
<p>will file an issue</p>



<a name="212084781"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Debuginfo%20treats%20projection%20like%20uses%20of%20the%20base%20local/near/212084781" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Debuginfo.20treats.20projection.20like.20uses.20of.20the.20base.20local.html#212084781">(Oct 02 2020 at 14:52)</a>:</h4>
<p>We should make sure <code>SimplifyLocals</code> still counts this as a use of <code>_6</code> though. We don't want to remove locals that are still used by debuginfo.</p>



<a name="212085426"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Debuginfo%20treats%20projection%20like%20uses%20of%20the%20base%20local/near/212085426" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Debuginfo.20treats.20projection.20like.20uses.20of.20the.20base.20local.html#212085426">(Oct 02 2020 at 14:57)</a>:</h4>
<p>good point. The visitor in <code>SimplifyLocals</code> should then overwrite <code>visit_var_debug_info</code> to make it a use again</p>



<a name="212085799"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Debuginfo%20treats%20projection%20like%20uses%20of%20the%20base%20local/near/212085799" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Debuginfo.20treats.20projection.20like.20uses.20of.20the.20base.20local.html#212085799">(Oct 02 2020 at 14:59)</a>:</h4>
<p>Hmm, it should already be correct if I'm reading <a href="https://github.com/rust-lang/rust/blob/4dedf5edd51d0e0b1b45a61403842f8406e13b2c/compiler/rustc_mir/src/transform/simplify.rs#L399">the code</a> correctly.</p>



<a name="212085980"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Debuginfo%20treats%20projection%20like%20uses%20of%20the%20base%20local/near/212085980" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Debuginfo.20treats.20projection.20like.20uses.20of.20the.20base.20local.html#212085980">(Oct 02 2020 at 15:01)</a>:</h4>
<p>Yeah, that's right <span aria-label="thumbs up" class="emoji emoji-1f44d" role="img" title="thumbs up">:thumbs_up:</span></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>